<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="title">
        #{msg['application.titre.visitor.consulter']}
    </ui:define>

    <ui:define name="ariane">
        <h:commandLink action="/index.xhtml"  > Accueil </h:commandLink> > Sessions (Planning)
    </ui:define>

    <ui:define name="content">

        <h:panelGroup styleClass="titre">Planning des sessions</h:panelGroup>
        <p:schedule value="#{visitorPlanningBean.eventModel}" 
                    locale="fr" 
                    style="width:700px" 
                    rightHeaderTemplate="month,agendaWeek"
                    editable="true"
                    showWeekends="false"
                    draggable="false"
                    firstHour="7"
                    minTime="7"
                    maxTime="19"
                    widgetVar="myschedule"
                    allDaySlot="false"
                    resizable="false"
                    initialDate="#{visitorPlanningBean.initialDateSchedule}"
                    >
            <p:ajax event="eventSelect" listener="#{visitorPlanningBean.onEventSelect}" update="eventDetails" oncomplete="eventDialog.show()" />
        </p:schedule>

        <p:dialog widgetVar="eventDialog" header="Informations" showEffect="clip" hideEffect="clip"> 
            <h:panelGrid id="eventDetails" columns="2">

                <h:outputLabel for="formation" value="Formation :" />
                <h:outputLabel for="forma" value="#{visitorPlanningBean.event.title}" />

                <h:outputLabel value="Date :"/>
                <h:outputLabel for="date" value="#{visitorPlanningBean.event.startDate}"/>

                <h:outputLabel value="Horaire :"/>

                <h:panelGrid id="horaire" columns="3">

                    <h:outputLabel for="horaire " value="#{visitorPlanningBean.seance.dateHeureDebut}">
                        <f:convertDateTime pattern="HH:mm"/>
                    </h:outputLabel>
                    -
                    <h:outputText value="#{visitorPlanningBean.seance.dateHeureFin}">
                        <f:convertDateTime pattern="HH:mm"/>
                    </h:outputText>
                </h:panelGrid>

                <h:outputLabel value="Durée :"/>
                <h:outputLabel for="duree" value="#{visitorPlanningBean.seance.duree} heure(s)"/>

                <h:outputLabel value="Salle :"/>
                <h:outputLabel value="#{visitorPlanningBean.seance.session.salle.libPiece}"/>
                
                <h:outputText value="Se connecter pour s'inscrire" rendered="#{!visitorPlanningBean.activerLienInscription()}"/>
                
                
                
                
                <p:commandLink styleClass="lienAction lienCreer"
                               value="#{msg['application.inscription']}"
                               action="#{visitorPlanningBean.creer()}"
                               update="popup"
                               rendered="#{visitorPlanningBean.activerLienInscription()}"/>

            </h:panelGrid>
        </p:dialog> 
    </ui:define>

    <ui:define name="popup">

        <h:panelGrid columns="2">
            <h:outputText value="Instructeur :"/>
            <h:outputText value="#{visitorPlanningBean.seance.session.instructeur}"/>
            <h:outputText value="Formation :"/>
            <h:outputText value="#{visitorPlanningBean.event.title}"/>

        </h:panelGrid>

        <h:panelGrid columns="1">
            
            <h:outputLabel for="inputInscription" value="Inscription"/>
            <p:selectOneMenu value="#{visitorPlanningBean.personnel}"
                             converter="#{genericConverter}" 
                             id="inputInscription"
                             >
                <f:selectItems value="#{visitorPlanningBean.listPersonnelSubordonne}" var="personnel" 
                               itemLabel="#{personnel.grade} #{personnel.nom}" id="selectPersonnel"/>
            </p:selectOneMenu>


            <h:outputLabel for="inputSeance"
                           value="Séances de la session sélectionnée :"/>
            <p:scrollPanel style="width: 350px;height: 200px">
            <p:dataTable var="uneSeance" value="#{visitorPlanningBean.seance.session.listSeance}" widgetVar="informationTable">
                <p:column headerText="Séance">
                    <h:outputText value="*" />
                </p:column>
                <p:column headerText="Date">
                    <h:outputText value="#{uneSeance.dateHeureDebut}">
                        <f:convertDateTime pattern="dd/MM/yy"/>
                    </h:outputText>
                </p:column>
                <p:column headerText="Horaire">
                    <h:outputText value="#{uneSeance.dateHeureDebut}">
                        <f:convertDateTime pattern="HH:mm"/>
                    </h:outputText>
                    -
                    <h:outputText value="#{uneSeance.dateHeureFin}">
                        <f:convertDateTime pattern="HH:mm"/>
                    </h:outputText>
                </p:column>
            </p:dataTable>  
            </p:scrollPanel>
        </h:panelGrid>

        <h:panelGrid columns="2" >
            <p:commandButton value="Inscrire"  
                             onclick="popup.hide()"
                             action="#{visitorPlanningBean.inscrire()}"
                             update="messages"
                             />
            <p:commandButton value="Annuler"   
                             onclick="hide()"
                             action="#{visitorPlanningBean.annuler}"
                             update="messages"/>
        </h:panelGrid>
    </ui:define>

</ui:composition>
